﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Gamego
{
    /// <summary>
    /// 障碍物
    /// </summary>
    class Barrier
    {
        //定义障碍物的属性
        public Rectangle Rectangle { get; set; }
        //定义下落的速度属性
        public int SpeedBarrier { get; set; }
        

        public Barrier(Rectangle rec)
        {
            Rectangle =rec;
            
        }
        //障碍物的移动函数
        public void Move()
        {

            //障碍物随着时间改变加速
            if (Game.GameStartTime != null)
            {
                int i = 25;
                var ts = System.DateTime.Now - Game.GameStartTime;
                if (ts.TotalSeconds >= 4)
                {
                    SpeedBarrier = 10 + i;
                }

                this.Rectangle = new Rectangle(this.Rectangle.X,
                                           this.Rectangle.Y + SpeedBarrier, 250, 30);

            }
        }
        //绘制障碍物
        public void Draw(Graphics g)
        {
            g.DrawImage(Properties.Resources.omg, Rectangle);

        }
        //障碍物以速度下落

    }
}